//
//  WSTouchScrollView.m
//  WSBaseKit
//
//  Created by zhangcong on 2020/8/18.
//  Copyright © 2020 zhangcong. All rights reserved.
//

#import "WSTouchScrollView.h"

@implementation WSTouchScrollView


//传递touch事件
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
    if(!self.dragging)
    {
        [[self nextResponder] touchesBegan:touches withEvent:event];
    }
    
    [super touchesBegan:touches withEvent:event];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    if(!self.dragging)
    {
        [[self nextResponder]touchesMoved:touches withEvent:event];
    }
    [super touchesMoved:touches withEvent:event];
}



- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
    if(!self.dragging)
    {
        [[self nextResponder]touchesEnded:touches withEvent:event];
    }
    [super touchesEnded:touches withEvent:event];
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    if (!self.dragging) {
        [[self nextResponder] touchesCancelled:touches withEvent:event];
    }
    [super touchesCancelled:touches withEvent:event];
}

- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view
{
    //返回yes 是不滚动 scroll 返回no 是滚动scroll
    
    if (view != self) {
        return YES;
    }
    return NO;
}

- (BOOL)touchesShouldCancelInContentView:(UIView *)view
{
    
//    NSLog(@"用户点击的视图 %@",view);
    
    //    if (view != self) {
    //        return NO;
    //    }
    
    //NO scroll不可以滚动 YES scroll可以滚动
    return YES;;
}



@end
